package cn.ecnu.mapper;


import cn.ecnu.entity.User;
import cn.ecnu.vo.ResetVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface UserMapper {

    @Select("select * from user where username = #{name}")
    User getUserByName(@Param("name") String name);

    @Select("select * from user where phone = #{phone}")
    User getUserByPhone(@Param("phone") String phone);

    @Select("select * from user where username = #{field} or phone = #{field}")
    User getUserByField(@Param("field") String field);

    @Select("select * from user where id = #{id}")
    User getUserById(@Param("id") String id);

    @Update("update logistic_system.user set password = #{password} where id = #{id}")
    int updateUserPasswordById(@Param("id") String id, @Param("password") String password);

    @Select("select * from user")
    List<User> getUserList();

    int insertUser(User user);

    int updateUser(ResetVo resetVo);

}
